#!/usr/bin/env bash

# ----------------------------------------------------------------------
# Filename:   01-packages-industrial.sh
# Version:    1.0
# Date:       2020/04/23
# Author:     Lz
# Email:      lz843723683@163.com
# History：     
#             Version 1.0, 2020/04/22
# Function:   packages - 01.测试金风工控版本包列表需
# Out:        
#              0 => TPASS
#              1 => TFAIL
#              other=> TCONF
# ----------------------------------------------------------------------

## TODO : 测试收尾清除工作
#
PkgClean_FTGW_INDUSTRIAL(){
	return $TPASS
}


## TODO: 调用程序退出函数
#    In: $1 => 调用脚本结果值
PkgExit_FTGW_INDUSTRIAL(){
        # 调用退出函数，其中调用了clean相关函数
	Exit_FTLIB ${1}
}


## TODO: 用户界面
#
PkgUSAGE_FTGW_INDUSTRIAL(){
	USAGE_FTLIB "金风工控版本 - 包列表需求"
}


## TODO : 测试前的初始化 
#  Out  : 
#         0 => TPASS
#         1 => TFAIL
#         other=> TCONF
PkgInit_FTGW_INDUSTRIAL(){
        # 调用初始化函数
	Init_FTLIB "PkgClean_FTGW_INDUSTRIAL"
        # 调用用户界面函数
 	PkgUSAGE_FTGW_INDUSTRIAL
}


## TODO ：默认开启ssh、psacct、network、iptables、crond、auditd、rsyslog、firewalld  kdump服务
#
PkgTest01_FTGW_INDUSTRIAL(){
        local svcArr="sshd psacct network crond auditd rsyslog firewalld kdump"

	SvcActiveArr_FTLIB "isActive" "no" "$svcArr"
	RetParse_FTLIB "要求已经激活以下服务 ${svcArr}" "False"

	SvcEnableArr_FTLIB "isEnable" "no" "$svcArr"
	RetParse_FTLIB "要求开机自启动以下服务 ${svcArr}" "False"
}


## TODO ：默认存在smartd、sysstat服务
#
PkgTest02_FTGW_INDUSTRIAL(){
        local svcArr="smartd sysstat"

        SvcExistArr_FTLIB "isExist" "no" "$svcArr"
        RetParse_FTLIB "要求存在以下服务 ${svcArr}" "False"
}


## TODO ：默认开启acpid 服务,如果不存在apcid，存在systemd也行
#
PkgTest03_FTGW_INDUSTRIAL(){
	AcpidEnable_FTGENREQ
}


## TODO ：默认安装rsync、openssl、openssl-devel、libaio、libaio-devel、libpng-devel、 pygobject2-devel、 libSM-devel、 libXrender-devel、 libXext-devel、ncurses-devel 、libXt-deve  ，zip ,   unzip  , gdb ,  gd-kylin-agent
#
PkgTest04_FTGW_INDUSTRIAL(){
	local pkgArr="rsync openssl openssl-devel libaio libaio-devel libpng-devel pygobject2-devel libSM-devel libXrender-devel libXext-devel ncurses-devel libXt-devel zip unzip gdb gd-kylin-agent"

	PkgExistArr_FTLIB "isExist" "no" "yes" "${pkgArr}"	
	RetParse_FTLIB "要求默认安装：${pkgArr}" "False"
}


## TODO : GCC版本为4.9.2
#
PkgTest05_FTGW_INDUSTRIAL(){
        local cmd="gcc"

        # 判断版本号
        VersionEQTest_FTLIB "${cmd}" "--version" "4.9.2"
}


## TODO : valgrind版本为3.15.0
#
PkgTest06_FTGW_INDUSTRIAL(){
        local cmd="valgrind"

        # 判断版本号
        VersionEQTest_FTLIB "${cmd}" "--version" "${cmd}-3.15.0"
}


## TODO : libasan版本为4.9.2
#
PkgTest07_FTGW_INDUSTRIAL(){
        local pkgname="libasan-4.9.2"

        # 判断版本号
        PkgExist_FTLIB "isExist" "no" "yes" "$pkgname"
        RetParse_FTLIB "要求 libasan 版本为 4.9.2" "False"
}


## TODO : Main
#  Out  : 
#         0 => TPASS
#         1 => TFAIL
#         other => TCONF
PkgMain_FTGW_INDUSTRIAL(){
	PkgInit_FTGW_INDUSTRIAL

	PkgTest01_FTGW_INDUSTRIAL

	PkgTest02_FTGW_INDUSTRIAL

	PkgTest03_FTGW_INDUSTRIAL

	PkgTest04_FTGW_INDUSTRIAL

	PkgTest05_FTGW_INDUSTRIAL

	PkgTest06_FTGW_INDUSTRIAL

	PkgTest07_FTGW_INDUSTRIAL

	return ${TPASS}	
}

PkgMain_FTGW_INDUSTRIAL
PkgExit_FTGW_INDUSTRIAL $?
